/*
* This file is part of Project SkyFire https://www.projectskyfire.org.
* See LICENSE.md file for Copyright information
*/

#ifndef SKYFIRE_FLEEINGMOVEMENTGENERATOR_H
#define SKYFIRE_FLEEINGMOVEMENTGENERATOR_H

#include "MovementGenerator.h"

template<class T>
class FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
{
public:
    FleeingMovementGenerator(uint64 fright) : i_frightGUID(fright), i_nextCheckTime(0) { }

    void DoInitialize(T*);
    void DoFinalize(T*);
    void DoReset(T*);
    bool DoUpdate(T*, uint32);

    MovementGeneratorType GetMovementGeneratorType() { return FLEEING_MOTION_TYPE; }

private:
    void _setTargetLocation(T*);
    void _getPoint(T*, float& x, float& y, float& z);

    uint64 i_frightGUID;
    TimeTracker i_nextCheckTime;
};

class TimedFleeingMovementGenerator : public FleeingMovementGenerator<Creature>
{
public:
    TimedFleeingMovementGenerator(uint64 fright, uint32 time) :
        FleeingMovementGenerator<Creature>(fright),
        i_totalFleeTime(time) { }

    MovementGeneratorType GetMovementGeneratorType() { return TIMED_FLEEING_MOTION_TYPE; }
    bool Update(Unit*, uint32);
    void Finalize(Unit*);

private:
    TimeTracker i_totalFleeTime;
};

#endif
